#!/bin/bash

## 性能测试程序
benchmark=./mbench
## 主机文件
machinefile=./machinefile
## 启动的进程数
proc_num=16
## 测试消息长度，目前消息最大只能测试到 64K/proc_num
msg_sz_array=(2 4 8 16 32 64 128 256 512 1024 2048 4032)
## 性能测试采样次数
sample_time=4
## 被测试操作类型
coll_ops="SCATTER_Latency"

## 基于TCP点对点的散发性能测试
target="mpich3"

if [[ $target = "mpich3" ]]; then
    echo "mpich3"
    export PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/ibutils/bin:/root/zyq/mpich3/mpich3-install/bin:/root/bin

     for msg_sz in ${msg_sz_array[@]}; do
        echo "--------" $msg_sz "--------" 
        mpicc mbench.c -o mbench
        mpiexec -n $proc_num -f $machinefile $benchmark $msg_sz $sample_time $coll_ops
        sleep 5
    done
## 基于UDP组播的散发性能测试
elif [[ $target = "mpich3-fsom" ]]; then
    echo "mpich3-fsom"
    export PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/ibutils/bin:/root/zyq/mpich3-fsom/mpich3-fsom-install/bin:/root/bin

     for msg_sz in ${msg_sz_array[@]}; do
        echo "--------" $msg_sz "--------" 
        mpicc mbench.c -o mbench
        mpiexec -n $proc_num -f $machinefile $benchmark $msg_sz $sample_time $coll_ops
        sleep 5
    done
fi

# mpicc  mbench.c -o mbench
# mpiexec -n $proc_num -f machinefile ./mbench $msg_sz $sample_time
